<!--
/**************************************************
* @ manufacturecategoryview.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/02/27, owen
*  1) first release
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>

<html>
<head>
<title>产品分类管理</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<%

	if(request.getAttribute("MSG") != null){
		out.print("<script language='javascript'>alert('"+request.getAttribute("MSG")+"');</script>");
	}

	ArrayList tManuf1 = (ArrayList)request.getAttribute("manufacture1");
	HashMap tMap1 = (HashMap)request.getAttribute("manufacturetyp2");
	if(tMap1 != null){
	    System.out.println(""+tMap1.size());
	}else{
	    System.out.println("false");
	}
	HashMap tMap2 = (HashMap)request.getAttribute("manufacturetyp3");
	if(tMap2 != null){
	    System.out.println(""+tMap2.size());
	}else{
	    System.out.println("false");
	}
	ArrayList tList1 = new ArrayList();    
	ResultProcess tGSManuf = (ResultProcess)request.getAttribute("manufacture");
	String tReQuery = (String)request.getAttribute("requery");
	
%>
<script language="JavaScript">

function process(val){
         if(val == 'Q' || val == 'Qre'){
				  if (val == 'Qre') {
					<%
					    if(tReQuery!=null && tReQuery.equals("true")){
					%>
						checkform.action='<%= response.encodeURL(request.getContextPath() + "/A400202.do") %>';
                        checkform.submit();
                        return true;
			    	<%}%>
		    	} else if (val == 'Q') {
						checkform.action='<%= response.encodeURL(request.getContextPath() + "/A400202.do") %>';
                        checkform.submit();
                        return true;
		    	}
    	
		}
 }

function add(){
   //checkform.action='<%=root%>/A400203.do';
   //checkform.submit();
   //window.open("<%=root%>/A400203.do");
   //return true;
   
       var result = null;	
		result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400203.do") %>", window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
		//alert(result);
		if(result != null){
		   orgform.gs_manufacture_category_id.value=result[0];
           orgform.gs_manufacture_category_name.value=result[1];
           orgform.gs_manufacture_level.value=result[2];
           orgform.gs_upper_manufacture_category.value=result[3];
           orgform.gs_manufacture_desc.value=result[4];
                      
           orgform.action = "<%= response.encodeURL(request.getContextPath() + "/A400204.do") %>";
		   orgform.submit();
		   //process('Q');
		}
    return true;
}
function clean(){
      checkform.category_name.value ="";
	  checkform.manuftype1.value="0";		
	  var listbox = document.getElementById("manuftype2");
			listbox.length = 0;
			var option = new Option();
			option.text = "---二级---";
			option.value = "0";			
			listbox.options[listbox.length] = option;	
    }
    
function mod(temp){
     
      pager.CategoryId.value=temp;
      
      var id=null;
      id= pager.CategoryId.value;
     
      var result = null;	
		result = showModalDialog("<%= response.encodeURL(request.getContextPath() + "/A400206.do") %>?categoryid="+id, window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:600px;help:no;");
		if(result != null){
		   //alert("产品分类信息修改成功!");
		   
		   orgform.gs_manufacture_category_id.value=result[0];
           orgform.gs_manufacture_category_name.value=result[1];
           orgform.gs_manufacture_level.value=result[2];
           orgform.gs_upper_manufacture_category1.value=result[3];
           orgform.gs_upper_manufacture_category2.value=result[4];
           orgform.gs_manufacture_desc.value=result[5];
           
           orgform.action="<%= response.encodeURL(request.getContextPath() + "/A400207.do") %>";   
		   orgform.submit();
           
		  // process('Q');
		}
    } 
function del(temp){
  if (confirm("是否删除此产品分类？")) {
   pager.CategoryId.value=temp;
   delform.CategoryId.value=temp;
   delform.action='<%= response.encodeURL(request.getContextPath() + "/A400205.do") %>';
   delform.submit();
   //pager.action='<%=root%>/A400205.do';
   //pager.submit();
   //window.location.reload();
   return true;
   }
}
function change1(optval){
  var val = optval;
  if(val=='0'){
    var listbox = document.getElementById("manuftype2");
    listbox.length = 0;
    var option = new Option();
    option.text = "---二级---";
    option.value = "0";
    listbox.options[listbox.length] = option;
    //change2(optval);
  }else{
      var counter="0";
    <%if(tMap1 !=null){
      Collection tCollection = tMap1.keySet();
      Iterator tIterator = tCollection.iterator();
      while(tIterator.hasNext()){
        String tKey = (String)tIterator.next();
        tList1 = (ArrayList)tMap1.get(tKey);%>
        if(val == '<%=tKey%>'){
		  counter = "1";
          var listbox = document.getElementById("manuftype2");
          listbox.length = 0;
          var option = new Option();
          option.value = "0";
          option.text = "---二级---";
          listbox.options[listbox.length] = option;
          <%
	          	for(int n=0;n<tList1.size();n++){
		            GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList1.get(n);
		            String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
		            String categoryName = tGSManufactureBean.getGs_manufacture_category_name();%>
		            var temp1 = '<%=categoryId%>';
		            var temp2 = '<%=categoryName%>';
		            var option = new Option();
		            option.value = temp1;
		            option.text = temp2;
		            listbox.options[listbox.length] = option;
           <%
	       		}
           %>
			//change2('0');           
         }
         
    <%
    	}
    %>
    	if(counter == '0'){
          var listbox = document.getElementById("manuftype2");
          listbox.length = 0;
          var option = new Option();
          option.value = "0";
          option.text = "---二级---";
          listbox.options[listbox.length] = option;  
         // change2('0');    	
    	}
    <%  
    }
    %>
   }
}
   
</script>
<%
	ResultProcess tCategoryList = (ResultProcess)request.getAttribute("CategoryList");
	ArrayList tList = new ArrayList();
%>
</head>
<body onload="process('Qre')">

<form name="orgform" method="post">
	<input type="hidden" name="gs_manufacture_category_id" >	
	<input type="hidden" name="gs_manufacture_category_name" >	
	<input type="hidden" name="gs_manufacture_level" >	
	<input type="hidden" name="gs_upper_manufacture_category" >	
	<input type="hidden" name="gs_upper_manufacture_category1" >	
	<input type="hidden" name="gs_upper_manufacture_category2" >	
	<input type="hidden" name="gs_manufacture_desc" >	
	
</form>

<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="98%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">产品分类管理</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>
<form name="checkform" method="get" >

<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
									
					<TD class="bg_column" align=center>所属产品分类</TD>
					<TD align=left class="bg_row_odd">
					    <select name="manuftype1" onChange="change1(this.value)">	
						<option value="0">---一级---</option>				
						<%
							String tManufType1 = request.getParameter("manuftype1");
							//int iManuType1 = 0;
							if(tManuf1 != null && tManuf1.size() > 0 ){
							    if(tManufType1 != null){
							        //iManuType1 = Integer.parseInt(tManufType1);
							    }
								for(int i=0; i<tManuf1.size(); i++){
								    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tManuf1.get(i);
								    if(tManufType1 != null && tManufType1.equals(tGSManufactureBean.getGs_manufacture_category_id())){
								        
						%>
								<option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>" selected>
								<%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
						<%			        
								    }else{
						%>
								<option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>">
								<%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
								
						<%			}	
								}
							}
						%>

						</select>
						<select id="manuftype2" name="manuftype2">	
						<option value="0">---二级---</option>				
						<%
							String tManufType2 = request.getParameter("manuftype2");
							if(tManufType1 != null && !tManufType1.equals("0")){
							    //int tIntManuType2 = Integer.parseInt(tManufType2);
							    ArrayList temp = (ArrayList)tMap1.get(tManufType1);
							    if(temp!= null && temp.size() > 0){
									for(int i=0; i<temp.size(); i++){
									    GSManufactureCategoryBean tGSManuf2 = (GSManufactureCategoryBean)temp.get(i);
									    if(tManufType2 != null && tManufType2.equals(tGSManuf2.getGs_manufacture_category_id())){
							%>
									<option value="<%=tManufType2%>" selected><%=tGSManuf2.getGs_manufacture_category_name()%></option>
							<%			        
									    }else{
							%>
									<option value="<%=tGSManuf2.getGs_manufacture_category_id()%>"><%=tGSManuf2.getGs_manufacture_category_name()%></option>
									
							<%			}	
									}
							    }
							}
						%>

						</select></TD>					
				    <TD class="bg_column" align=center>产品分类名称</TD>
					<TD left=right class="bg_row_odd">
						 <input type="text" name="category_name" value="<%=request.getParameter("category_name")==null? "":request.getParameter("category_name")%>" maxLength=100 size="24">
						 </input>
					</TD>
				</TR>
				
			</table>
		</td>
	</tr>
</table>
<%
if(tCategoryList != null){
                    int totalRecords = 0;
                    int defaultPageSize = 10;
                    totalRecords = tCategoryList.getRecordsSize();
            %>          
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
            <%tList = tCategoryList.getDisplayRecords(index.intValue(),pageSize.intValue()); %>
            </page:pager>
            <%} %>
</form>
    <p align="center">  
		<input type="button" class="kuang" value="查询" onclick="process('Q')"/>&nbsp;
		<input type="button" class="kuang" value="清空" onclick="clean()"/>&nbsp;				
		
    </p>
<%
	
	if(tCategoryList != null){
%>
	<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name='pager' method="post">
            <input type=hidden name="ProviderId" >
            <input type=hidden name="CategoryId" >
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=98% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20>
                        <td class=top align=middle> 
						</td> 
                      <!--   <td class=top align=middle> 
						</td>
						 -->
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类编号</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类名称</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类级别</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类一级编号</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类二级编号</div>
						</td>																																		
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品种类描述</div>
						</td>																	
					</tr>
					  <%
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							String[] tStr = (String[])tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
					%>
							<tr <%=tTempStr%> height=20>
							    <td class=top align=middle> 
							<div align="center" class="txt_content">
                                 <input type="button" class="kuang" value="修改" onclick="mod('<%=tStr[0] %>')"/>
                            </div>
								</td>
							    <!-- <td class=top align=middle> 
						        <div align="center" class="txt_content">
                                <input type="button" class="kuang" value="删除" onclick="del('<%=tStr[0] %>')"/>
                               </div>	
								</td> -->
							
								<td class=top align=middle> 
								<div align="center" class="txt_content">
                                  <%=tStr[0]%>
                                </div>	
								</td>								
								<td class=top align=middle> 
							    <div align="center" class="txt_content">
                                 <%=tStr[1]%>
                                </div>
								</td>
								<td class=top align=middle> 
								<div align="center" class="txt_content">
                                 <%=tStr[2]%>
                                </div>
								</td>								
								<td class=top align=middle> 
							      <div align="center" class="txt_content">
                                    <%=tStr[3]%>
                                  </div>
								</td>								
								<td class=top align=middle> 
								 <div align="center" class="txt_content">
                                   <%=tStr[4]%>
                                 </div>
								</td>	
																							
								<td class=top align=middle> 
							     <div align="center" class="txt_content">
                                   <%=tStr[5]%>
                                 </div>
								</td>																	
							</tr> 
							
					<%	
							}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="10" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm="checkform"/>
						    </td>
						  
				    <%
						}else{
					%>
							<font color="red">没有符合条件的产品种类</font>
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
	
	<form action="" name="delform" method="post">	
     <input type=hidden name=CategoryId>		
    </form>

	<p align="center">  
		<input type="button" class="kuang" value="增加" onclick="add()"/>&nbsp;
    </p>
<%		
	}
%>
</body>
</html>